/**
 * Copyright (C), 2015-2018, XXX有限公司
 * FileName: CpConfigController
 * Author:   sjk
 * Date:     2018-08-01 12:44
 * Description: cp配置信息
 * <author>          <time>          <version>          <desc>
 * 作者姓名         修改时间           版本号            描述
 */
package com.cdqidi.smsservice.controller.api;

import com.cdqidi.smsservice.exception.ApiException;
import com.cdqidi.smsservice.service.CpConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotBlank;

/**
 * 〈一句话功能简述〉<br>
 *
 * @author sjkyll
 * @since 1.0.0
 */
@RestController
@RequestMapping(value = "/auth")
@Validated
public class CpConfigController {

    private final CpConfigService cpConfigService;

    @Autowired
    public CpConfigController(CpConfigService cpConfigService) {
        this.cpConfigService = cpConfigService;
    }

    @RequestMapping(value = "/getAccessToken")
    public Object getAccessToken(@RequestParam(name = "appid") @NotBlank(message = "appid不能为空") String appId,
                                 @RequestParam(name = "appsecret") @NotBlank(message = "appsecret不能为空") String appSecret) throws ApiException {
        return cpConfigService.getAccessToken(appId, appSecret).getData();
    }
}